<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<md-step label="Deployment" md-complete="$ctrl.parent.vm.stepData[4].data.completed" ng-disabled="$ctrl.parent.vm.stepProgress < 5">
  <md-step-body>
    <md-content flex layout-padding class="gv-abstract-content gv-creation-content">
      <h5>
        API
        <a ng-click="$ctrl.parent.selectStep(0)">
          <md-tooltip>Jump to general edition</md-tooltip>
          <ng-md-icon icon="mode_edit" size="20"></ng-md-icon>
        </a>
      </h5>
      <p>
        You are about to create the API <code>{{$ctrl.parent.api.name}}</code> in version <code>{{$ctrl.parent.api.version}}</code>. The API
        will be map to the following context path <code>{{$ctrl.parent.api.proxy.context_path}}</code>.
        <span ng-if="$ctrl.parent.api.groups && $ctrl.parent.api.groups.length > 0">
          The groups <code ng-repeat="group in $ctrl.parent.api.groups" style="margin: 0 0.2rem">{{group.name}}</code> will be able to
          access the API.
        </span>
      </p>
      <h5>
        Gateway
        <a ng-click="$ctrl.parent.selectStep(1)">
          <md-tooltip>Jump to gateway edition</md-tooltip>
          <ng-md-icon icon="mode_edit" size="20"></ng-md-icon>
        </a>
      </h5>
      <p>The upstream endpoint will be <code ng-repeat="endpoint in $ctrl.parent.api.proxy.endpoints">{{endpoint.target}}</code>.</p>
      <h5>
        Plan
        <a ng-click="$ctrl.parent.selectStep(2)">
          <md-tooltip>Jump to plan edition</md-tooltip>
          <ng-md-icon icon="mode_edit" size="20"></ng-md-icon>
        </a>
      </h5>
      <p ng-if="$ctrl.parent.api.plans.length > 0">
        The <code>{{$ctrl.parent.api.plans[0].name}}</code> plan will allow users to subscribe to the API. The
        <code>{{$ctrl.parent.api.plans[0].security}}</code> plan security scheme means that the API
        <span ng-if="$ctrl.parent.api.plans[0].security === 'KEY_LESS'"
          >will be open access and causes API Gateway to bypass any access control mechanisms.</span
        >
        <span ng-if="$ctrl.parent.api.plans[0].security === 'API_KEY'"
          >will enforce verification of API Keys during request processing, letting only apps with approved API Keys access the API.</span
        >

        The plan has validation mode set to <code>{{$ctrl.parent.api.plans[0].validation}}</code> meaning that application developers
        <span ng-if="$ctrl.parent.api.plans[0].validation === 'AUTO'">can subscribe to this Plan immediately.</span>
        <span ng-if="$ctrl.parent.api.plans[0].validation === 'MANUAL'"
          >have to request approval for access to subscribe to this Plan.</span
        >
      </p>
      <p ng-if="$ctrl.parent.api.plans.length == 0" class="gv-abstract-warning">
        <ng-md-icon icon="warning" style="fill: orange"></ng-md-icon> No plan means that nobody can subscribe and consume your API.
      </p>
      <h5>
        Documentation
        <a ng-click="$ctrl.parent.selectStep(3)">
          <md-tooltip>Jump to documentation edition</md-tooltip>
          <ng-md-icon icon="mode_edit" size="20"></ng-md-icon>
        </a>
      </h5>
      <p ng-if="$ctrl.parent.api.pages.length > 0">
        The API will have the <code ng-repeat-start="page in $ctrl.parent.api.pages" ng-bind="page.name"></code>
        <span ng-repeat-end></span>documentation to helping users understand and use the API.
      </p>
      <p ng-if="$ctrl.parent.api.pages.length == 0" class="gv-abstract-warning">
        <ng-md-icon icon="warning" style="fill: orange"></ng-md-icon> No documentation provided, remember to provide consumers
        understandable and accurate information about your API.
      </p>
      <h5>Confirmation</h5>
      <p style="padding-top: 0px" ng-if="!$ctrl.parent.Constants.env.settings.apiReview.enabled">
        You can now either
        <strong
          ><md-button class="md-raised" ng-click="$ctrl.parent.createAPI(false)">create the API without deploying it</md-button></strong
        >
        letting you continue configure the API or
        <strong><md-button class="md-raised" ng-click="$ctrl.parent.createAPI(true)">create and start the API</md-button></strong> to make
        it immediately available for the application developers.
      </p>
      <p style="padding-top: 0px" ng-if="$ctrl.parent.Constants.env.settings.apiReview.enabled">
        You can now either
        <strong><md-button class="md-raised" ng-click="$ctrl.parent.createAPI(false, false)">create the API in draft</md-button></strong>
        letting you continue configure the API or
        <strong
          ><md-button class="md-raised" ng-click="$ctrl.parent.createAPI(false, true)">create the API and ask for review</md-button></strong
        >
        before publishing/starting it.
      </p>

      <div layout="row">
        <a ng-href="{{$ctrl.url}}" target="_blank" class="gv-abstract-documentation-link" flex
          >To go further on API configuration, please consult <strong>API Management documentation</strong></a
        >
      </div>
    </md-content>
  </md-step-body>
</md-step>
